package com.station.search.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.station.search.constant.DeleteEnum;
import com.station.search.domain.StationQuestion;
import com.station.search.mapper.StationQuestionMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: JT
 * @date: 2021/8/31
 * @Title: 台站问题业务层实现
 */
@Service
public class StationQuestionServiceImpl extends ServiceImpl<StationQuestionMapper, StationQuestion> implements StationQuestionService {

    @Resource
    private StationQuestionMapper stationQuestionMapper;

    @Override
    public List<StationQuestion> queryStationQuestions(String stationId) {
        Map<String, Object> queryParams = new HashMap<String, Object>(){{
            {
                put("STATION_CODE", stationId);
                put("IS_DELETED", DeleteEnum.NOT_DELETED.getValue());
            }
        }};
        return stationQuestionMapper.selectByMap(queryParams);
    }

    @Override
    public void deleteQuestionById(String questionId) {
        StationQuestion stationQuestion = new StationQuestion();
        stationQuestion.setId(questionId);
        stationQuestion.setIsDeleted(DeleteEnum.IS_DELETED.getValue());
        stationQuestion.setDeletedDate(new Date());
        this.updateById(stationQuestion);
    }
}
